package com.itheima.mArray;
/*
遍历数组求最值
 */
public class ArrayDemo04 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6};
        int max = arr[0];
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(max<arr[i]){
                max = arr[i];
            }
            if(min>arr[i]){
                min = arr[i];
            }
        }
        System.out.println("最大值为:"+max);
        System.out.println("最小值为:"+min);
    }
}
